# 获取当前脚本目录位置
cd `dirname $0`
dir=`pwd`
echo ${dir}

# 执行发行版升级
# sudo zypper dist-upgrade
sudo zypper dup

#------------------------------------------------------------------------------
# 安装基本组件
sudo zypper in xorg-x11

sudo zypper in i3-gaps

# c 编译环境 依赖库
sudo zypper in make gcc g++ make ccache flex autoconf mercurial  harfbuzz-devel

# 依赖库
sudo zypper in xorg-x11
sudo zypper in ghc-X11-devel
sudo zypper in ghc-X11-devel

# 文本编辑器:sublime-text sublime-merge
sudo rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
# 刷新软件源
sudo zypper refresh      
sudo zypper addrepo -g -f https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo
sudo zypper install sublime-text
sudo zypper install sublime-merge

### fcitx5
sudo zypper addrepo -g -f  http://download.opensuse.org/repositories/M17N/openSUSE_Tumbleweed/M17N.repo
sudo zypper install fcitx5
sudo zypper install fcitx5-rime

# 刷新软件源
sudo zypper refresh  


# 设置登录管理器:sddm
sudo zypper in sddm
# 开机启动
systemctl enable sddm
# + 修改登录管理器设置
# 1、使用管理员权限，找到路径/etc/sysconfig/目录，找到displaymanager文件，编辑其中的"DISPLAYMANAGER="选项，等号后边内容改为你想替换的登录管理器名称，如：从"gdm"更改为"sddm"，（即将gnome的登录管理器gdm，改为的登录管理器sddm）保存退出当前配置文件。
# 2、找到相同目录下的windowmanager文件，编辑其中的“DEFAULT_WM=”选项，等号后边内容修改为你想要替换的桌面管理器，如：由"gnome"改为"kde"，保存文件，退出，重启系统即可。

##> 若一开始是用 服务器版安装的需要调整runlevel 为 5 才能启动后自动进入图形页面
#3.删除原始链接文件，重新确立链接文件
sudo mv /etc/systemd/system/default.target /etc/systemd/system/default.target-bak
sudo ln -s /usr/lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

# 备份 i3配置文件
mv ~/.config/i3 ~/.config/i3-bak`date +%y%m%d%H%M%S`
# 建立软链接命令拼接
cmdStr="ln -s  "${dir}"/../i3  "${HOME}"/.config/i3"
echo "执行命令: ${cmdStr} 建立软链接"
${cmdStr}

# 电源管理
sudo zypper in acpi acpid

# 亮度调节
# sudo zypper in light
sudo zypper in xbacklight

## 安装声卡与声音设置组件
sudo zypper in alsa-utils pulseaudio-alsa  
sudo zypper in paprefs pavucontrol 
sudo zypper in pasystray
sudo zypper in pulseaudio pulseaudio-alsa
# > alsamixer   # F3或F5 选择声卡，M键开启或关闭 显示“00”为开启
# > kmix为图形界面音量管理(需要先安装 alsa alsa-utils)
sudo zypper in kmix


# Other
sudo zypper in git
sudo zypper in tig

sudo zypper in ack
sudo zypper in fzf
sudo zypper in ripgrep

sudo zypper in bat

## i3lock-color
sudo zypper addrepo https://download.opensuse.org/repositories/home:bfein/openSUSE_Tumbleweed/home:bfein.repo
sudo zypper refresh
sudo zypper install i3lock-color

## wechat-uos
sudo zypper addrepo https://download.opensuse.org/repositories/home:zzndb001/openSUSE_Tumbleweed/home:zzndb001.repo
sudo zypper refresh
sudo zypper install wechat-uos

## VS_Code
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo zypper addrepo https://packages.microsoft.com/yumrepos/vscode vscode
sudo zypper refresh
sudo zypper install code

### or
# sudo zypper install flatpak
# flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
# flatpak install flathub com.visualstudio.code
# flatpak run com.visualstudio.code

## xmind.ZEN
sudo zypper install flatpak
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub net.xmind.ZEN
flatpak run net.xmind.ZEN
